<?php
namespace Services\Api;
use Common\Common;
use Common\Models\Orders;
use Common\Models\User;
use Services\ServicesApiBase;
class OrderServices extends ServicesApiBase
{

    public function order_list($data,$page,$pageSize){
        $model = new Orders();
        $list = $model->getOrderList($data,$page,$pageSize);
        $list_items['items'] = Common::transition_array($list);
        //后面可能改，订单存好店铺
        foreach($list_items['items'] as $key=>$value) {
            $list_items['items'][$key]['estimate_time'] = $value['order_paid_time'];
            if(substr($value['goods_pic'], 0, strlen('//')) === '//'){
                $list_items['items'][$key]['goods_pic'] = 'https:'.$value['goods_pic'];
            }
            $list_items['items'][$key]['money'] = Common::bc($value['money'],'0','+');
            switch ($value['site']) {
                case 'haodanku':
                    $list_items['items'][$key]['ShopType'] = '淘宝';
                    break;
                case 'elm':
                    $list_items['items'][$key]['ShopType'] = '饿了么';
                    break;
                case 'taobao':
                    $list_items['items'][$key]['ShopType'] = '淘宝';
                    break;
                case 'koubei':
                    $list_items['items'][$key]['ShopType'] = '口碑';
                    break;
                case 'jd':
                    $list_items['items'][$key]['ShopType'] = '京东';
                    break;
                case 'pdd':
                    $list_items['items'][$key]['ShopType'] = '拼多多';
                    break;
                case 'vph':
                    $list_items['items'][$key]['ShopType'] = '唯品会';
                    break;
                case 'duomai':
                    $list_items['items'][$key]['ShopType'] = '综合';
                    break;
            }

            //开启隐私订单
            $user       = new User();
            $userInfo   = $user->find_by_id_columns($value['user_id'], 'is_privacy');
            $is_privacy = isset($userInfo->is_privacy) ? $userInfo->is_privacy : 1;
            if ($is_privacy == 1 && $data['commission_type'] == 2) {
                $list_items['items'][$key]['is_privacy'] = true;
                $list_items['items'][$key]['goods_name'] = '**************';
                $list_items['items'][$key]['goods_pic']  = 'http://qn.enshitc.com/ysdd.png';
            }
        }
        return $list_items;
    }
}